﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ListOfTale
{
    /// <summary>
    /// Interaction logic for KeyForm.xaml
    /// </summary>
    public partial class KeyForm : Window
    {
        public KeyForm()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            ListOfTale.TalesDataSet talesDataSet = ((ListOfTale.TalesDataSet)(this.FindResource("talesDataSet")));
            ListOfTale.TalesDataSetTableAdapters.KeysTableAdapter talesDataSetKeysTableAdapter = new ListOfTale.TalesDataSetTableAdapters.KeysTableAdapter();
            talesDataSetKeysTableAdapter.Fill(talesDataSet.Keys);
            System.Windows.Data.CollectionViewSource keysViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("keysViewSource")));
            keysViewSource.View.MoveCurrentToFirst();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ListOfTale.TalesDataSet talesDataSet = ((ListOfTale.TalesDataSet)(this.FindResource("talesDataSet")));
                var keys = new TalesDataSetTableAdapters.KeysTableAdapter();
                keys.Update(talesDataSet.Keys);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Close();
        }


    }
}
